Skip to content

Fix agent init: container resource management and stale UX text#7607

Merged
trangevi merged 3 commits intoAzure:mainfrom
therealjohn:fix/patch-7605-7599-7598
Apr 9, 2026
Merged

Fix agent init: container resource management and stale UX text#7607
trangevi merged 3 commits intoAzure:mainfrom
therealjohn:fix/patch-7605-7599-7598

Conversation

@therealjohn
Copy link
Copy Markdown
Contributor

Fixes #7598, #7599, #7605

Changes

Container resource parsing and init-time selection (#7598, #7599)

  • Add ContainerResources type (cpu/memory) to ContainerAgent in the agent YAML schema so resource allocation is parsed from and persisted to agent.yaml
  • Move the container resource prompt before writing agent.yaml so the user's selection is saved into the definition file (previously it ran in addToProject, after the file was already written)
  • Pre-select the resource tier matching the manifest's existing resources values when prompting
  • Add tests for resource parsing, round-trip marshaling, and the nil-resources case

Remove stale replica mention (#7605)

  • Replace "cpu, memory, and replica settings" with "other settings" in the init-from-code post-init message, since replica configuration is no longer exposed in agent.yaml

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes agent init regressions in the azure.ai.agents azd extension by ensuring container resource settings (CPU/memory) are parsed from manifests, persisted into the generated agent.yaml, and that init UX text no longer references replica settings.

Changes:

  • Add a resources (CPU/memory) shape to the hosted/container agent YAML schema and validate parsing + marshaling via tests.
  • Move the container resource selection prompt earlier (before writing agent.yaml) and preselect a tier that matches existing manifest resources.
  • Update init-from-code post-init messaging to remove the stale “replica” mention.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/yaml.go Adds ContainerResources and wires it into ContainerAgent so resources round-trips in agent.yaml.
cli/azd/extensions/azure.ai.agents/internal/pkg/agents/agent_yaml/parse_test.go Adds tests covering resource parsing, YAML round-trip, and nil-resources omission behavior.
cli/azd/extensions/azure.ai.agents/internal/cmd/init.go Prompts for CPU/memory before writing agent.yaml, preselects based on manifest values, and reuses selected settings when updating azure.yaml.
cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go Updates post-init message to remove the outdated “replica settings” language.

Copy link
Copy Markdown
Member

@jongio jongio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI caught a gofmt alignment issue in the InitAction struct fields (init.go:69) - run gofmt -s -w . to fix. Logic looks correct - moving the resource prompt before writeAgentDefinitionFile properly ensures resources persist in agent.yaml. Tested both the populated and nil-resources cases. LGTM pending the formatting fix.

@trangevi trangevi merged commit f3266fd into Azure:main Apr 9, 2026
19 checks passed
Copy link
Copy Markdown
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review — PR #7607

Fix agent init: container resource management and stale UX text by @therealjohn

Summary

Clean, well-scoped fix. Moving the container resource prompt before writeAgentDefinitionFile correctly ensures the user's selection is persisted into agent.yaml. The ContainerResources type addition uses proper omitempty tags, and the tests cover parsing, YAML round-trip, and nil-resources omission thoroughly. One minor robustness note below.

🟢 Low (1 finding)

  1. Resource tier pre-selection uses exact string equalityt.Cpu == manifestResources.Cpu && t.Memory == manifestResources.Memory (init.go:1312) requires exact format match. Manually edited manifests with different representations (e.g., 0.250 vs 0.25) won't pre-select correctly. Low impact — falls back gracefully to the first tier.

✅ What Looks Good

  • ContainerResources with proper omitempty tags — marshaling correctly omits when nil
  • Same YAML library (go.yaml.in/yaml/v3) used in both production and tests
  • a.containerSettings pattern matches existing a.deploymentDetails state management
  • Prior review items resolved — @jongio's gofmt issue noted, @trangevi's design questions addressed
  • Text fix removes stale "replica settings" reference
Priority Count
Low 1
Total 1

Overall Assessment: Approve — clean, well-tested fix with no bugs found.

Review performed with GitHub Copilot CLI

if manifestResources != nil {
for i, t := range project.ResourceTiers {
if t.Cpu == manifestResources.Cpu && t.Memory == manifestResources.Memory {
defaultIndex = int32(i)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Low] Resource tier pre-selection uses exact string equality

t.Cpu == manifestResources.Cpu && t.Memory == manifestResources.Memory requires exact format match. Manually edited manifests with variant representations (e.g., 0.250 vs 0.25, 512Mi vs 0.5Gi) won't pre-select the matching tier. Falls back gracefully to first tier — not a bug, just a robustness note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generated agent definitions start with schema warnings

5 participants